# 王牌思路
class Solution:

    def alternateDigitSum(self, n: int) -> int:
        a, p = 0, -1
        while n > 0:
            p *= -1
            a += (n % 10) * p
            n //= 10
        return a * p


class Solution:

    def alternateDigitSum(self, n: int) -> int:
        a = 0
        while n > 0:
            a = n % 10 - a
            n //= 10
        return a